package com.hsd.controller;

import com.hsd.entity.Category;
import com.hsd.service.ICategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class CategoryController {

    @Resource
    private ICategoryService iCategoryService;

    /**
     * 使用ModelAndView向视图层传参
     * @return
     */
    @RequestMapping("test/sendToView")
    public ModelAndView sendToJSP(){
        List<Category> list = iCategoryService.findAll();
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("category", list);
        ModelAndView modelAndView = new ModelAndView("../right.jsp", map);
        return modelAndView;
    }
}
